home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Extender Bars (Kashidas).c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.5 KB  |  100 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17.  
  18. #include "SampleInterface.h"
  19.  
  20. short MyStrLen(char *x);
  21. static short MyStrLen(x)
  22. char    *x;
  23.     {
  24.     short c = 0;
  25.     while (*x++) c++;
  26.     return c;
  27.     }    /* MyStrLen */
  28.  
  29. static char arabicString[8] = {'\xE5', '\xC7', '\xE3', '\xE6', '\xCA', '\xE8', '\xD4', 0};
  30.  
  31. void ExtenderBars(WindowPtr sampleWindow)
  32.     {
  33.     /* Variables */
  34.     char                                *myString = (char *) &arabicString[0];
  35.     gxLayoutOptions                gxLayoutOptions;
  36.     gxLine                                myLine;
  37.     gxPoint                                myPoint;
  38.     gxRunControls                    gxRunControls;
  39.     gxShape                                layout;
  40.     short                                len, level = 0;
  41.     gxStyle                                myStyle;
  42.     gxViewPort                        aViewPort;
  43.     
  44.     /* Initialization */
  45.     
  46.     myPoint.x = ff(30);
  47.     myPoint.y = ff(50);
  48.     
  49.     aViewPort = GXNewWindowViewPort(sampleWindow);
  50.     SetDefaultViewPort(aViewPort);
  51.     
  52.     len = MyStrLen(myString);
  53.     InitializeRunControls(&gxRunControls);
  54.     
  55.     InitializeLayoutOptions(&gxLayoutOptions);
  56.     gxLayoutOptions.width = ff(500);
  57.     gxLayoutOptions.just = 0;
  58.     
  59.     myLine.first.x = myLine.last.x = myPoint.x;
  60.     myLine.first.y = 0;
  61.     myLine.last.y = ff(1000);
  62.     GXDrawLine(&myLine);
  63.     
  64.     myLine.first.x = myLine.last.x = myPoint.x + gxLayoutOptions.width;
  65.     GXDrawLine(&myLine);
  66.     
  67.     myStyle = NewLayoutStyle((char *) "\pDiwan", ff(50), gxNoMetricsGridText, nil, nil, 0, nil);
  68.     
  69.     layout = GXNewLayout(
  70.         1, &len, (void *) &myString,
  71.         1, &len, &myStyle,
  72.         1, &len, &level,
  73.         &gxLayoutOptions, &myPoint);
  74.     GXDrawShape(layout);
  75.     
  76.     gxLayoutOptions.just = fract1 / 4;
  77.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  78.     GXMoveShape(layout, 0, ff(75));
  79.     GXDrawShape(layout);
  80.     
  81.     gxLayoutOptions.just = fract1 / 2;
  82.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  83.     GXMoveShape(layout, 0, ff(75));
  84.     GXDrawShape(layout);
  85.     
  86.     gxLayoutOptions.just = 3 * (fract1 / 4);
  87.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  88.     GXMoveShape(layout, 0, ff(75));
  89.     GXDrawShape(layout);
  90.     
  91.     gxLayoutOptions.just = fract1;
  92.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  93.     GXMoveShape(layout, 0, ff(75));
  94.     GXDrawShape(layout);
  95.     
  96.     GXDisposeShape(layout);
  97.     GXDisposeStyle(myStyle);
  98.     GXDisposeViewPort(aViewPort);
  99.     }    /* main */
  100.